/**
 * @file BaseFunByOneVar.h
 * @author 世慷 (shikang999@126.com)
 * @brief 常规一个变量的激活函数基类
 * @version 0.1
 * @date 2025-10-01
 * 
 * @copyright Copyright (c) 2025
 * 
 */

#pragma once
#include "BaseFun.h"

namespace Net
{

class BaseFunByOneVar : public BaseFun
{
public:
    BaseFunByOneVar(FunType_E type, const std::string &name);
    virtual ~BaseFunByOneVar();

    //函数
    void fun(std::shared_ptr<NetLayer> &layer) final;

    //导数
    void diff(std::shared_ptr<NetLayer> &layer) final;

protected:
    //函数实现
    virtual Value_t runFun(Value_t x) = 0;

    //导数实现
    virtual Value_t runDiff(Value_t x) = 0;

private:
    void runLayerFun(std::shared_ptr<BaseNodeVar> &src, std::shared_ptr<BaseNodeVar> &dst);

    void runLayerDiff(std::shared_ptr<BaseNodeVar> &src, std::shared_ptr<BaseNodeVar> &dst);
};

}